//  ajax.js
//  一个简单的ajax类，自己用，高手不要谈论通用性和代码优化了
//  简单实现get post传值
//  2008 07 05
//  param requestType get/post
var response;
function Ajax(requestType,requestUrl,QueryString,handleResponse)
{
	if(window.XMLHttpRequest)           //firefox
	{
		request = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)        //windows
	{
		request = new ActiveXObject("Microsoft.XMLHTTP");
		if(!request)
		{
			request = new ActivXObject("Msxml2.XMLHTTP");
		}
	}
	if(!request)                             //if unsupport
	{
		alert("Your Browns don't support the application(Ajax)!");
	}
	else
	{
		//request.method = requestType;
		request.onreadystatechange = handleResponse;

		
		if(requestType.toLowerCase()=="post")            //if post
		{
			request.open(requestType,requestUrl,true);
			request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
			request.send(QueryString);
		}
		else                                       //if get
		{
			request.open(requestType,requestUrl+"?"+QueryString,true);
			request.send(null);
		}
	}
}

function handleResponse()           //callback
{
	if(request.readyState==4)   //已经完成
	{
		if(request.status==200)  //找到数据
		{
            alert(request.responseText);
		}
		else                       //404 未找到
		{
			alert("Can't find the server!");
		}
	}
}